﻿Public Class ClassAuto
    'Automation provider pour les macros vbscript

    Public ChercheFichiers As ClassChercheFichiers = FormChercher.ChercheFichiers

    Public Function GetTexteMarqueCurseur(Optional Format As String = "$0") As String
        'Retourne le texte marqué à la position du curseur, transformé selon le masque d'extraction spécifié
        Dim sNom As String = ""
        If Form1.RichTextBox1.Text <> "" Then
            'On commence avec la ligne courante pour aller plus vite
            Dim iPosCurseur As Integer = Form1.RichTextBox1.SelectionStart
            Dim iLigneCurseur As Integer = Form1.RichTextBox1.GetLineFromCharIndex(iPosCurseur)
            Dim iPosLigne As Integer = iPosCurseur - Form1.RichTextBox1.GetFirstCharIndexFromLine(iLigneCurseur)
            sNom = GetTexteMarquePos(Form1.RichTextBox1.Lines(iLigneCurseur), iPosLigne, Format)
            'Si on a rien, on essai avec le texte entier
            If sNom = "" Then sNom = GetTexteMarquePos(Form1.RichTextBox1.Text, iPosCurseur, Format)
        End If
        Return sNom
    End Function

    Public Function GetTexteMarquePos(ByVal Texte As String, ByVal Position As Integer, Optional Format As String = "$0") As String
        'Retourne le nom du marqueur qui s'applique à la position courante
        Dim sTexte As String = ""
        Dim oMarqueur As ClassMarqueur
        For Each oItem As ListViewItem In Form1.ListViewMarqueurs.Items
            oMarqueur = oItem.Tag
            Dim oColMatch As System.Text.RegularExpressions.MatchCollection
            Dim oCode As New ClassMacro 'Pour évaluation des conditions
            Dim Options As System.Text.RegularExpressions.RegexOptions = System.Text.RegularExpressions.RegexOptions.Multiline
            If oMarqueur.SensibleCasse = Boolean.FalseString Then Options = Options Or System.Text.RegularExpressions.RegexOptions.IgnoreCase
            If oMarqueur.Multi = Boolean.TrueString Then Options = Options Or System.Text.RegularExpressions.RegexOptions.Singleline
            Try
                oColMatch = System.Text.RegularExpressions.Regex.Matches(Texte, oMarqueur.Masque, Options)
                For Each oMatch As System.Text.RegularExpressions.Match In oColMatch
                    Dim bRetenu As Boolean = True
                    If oMarqueur.Condition <> "" Then bRetenu = oCode.EvalCondition(oMatch, oMarqueur.Condition)
                    If bRetenu Then
                        If oMatch.Index <= Position And oMatch.Index + oMatch.Length >= Position Then
                            sTexte = Format
                            For Each oSubMatch As System.Text.RegularExpressions.Group In oMatch.Groups
                                For iSubMatch As Integer = 0 To oMatch.Groups.Count - 1
                                    sTexte = sTexte.Replace("$" & iSubMatch.ToString("0"), oMatch.Groups(iSubMatch).Value)
                                    sTexte = System.Text.RegularExpressions.Regex.Replace(sTexte, "\$No", oMatch.Index.ToString("0"), System.Text.RegularExpressions.RegexOptions.IgnoreCase)
                                Next
                            Next
                        End If
                    End If
                Next
            Catch Ex As Exception
            End Try
        Next
        Return sTexte
    End Function

    Public Sub Separation(ByVal TousDoc As Boolean, ByVal Regex As String, ByVal ModeleContenu As String, ByVal ModeleNom As String)
        Call Form1.Separation(TousDoc, Regex, ModeleContenu, ModeleNom)
    End Sub

    Public Sub IntersectionListes(ByVal bSupprimer As Boolean)
        Call Form1.IntersectionListes(bSupprimer)
    End Sub

    Public Sub Fusion(ByVal TousDoc As Boolean, ByVal Regex As String, ByVal TypeFusion As Integer, ByVal Trier As Boolean, ByVal Doublons As Boolean, ByVal ParSource As Boolean, ByVal Stat As Boolean, Optional Modele As String = "$0")
        'Définir les paramètres
        FormFusion.CheckBoxDoublons.Checked = Doublons
        FormFusion.CheckBoxGrouper.Checked = ParSource
        FormFusion.CheckBoxStat.Checked = Stat
        FormFusion.CheckBoxTrier.Checked = Trier
        FormFusion.RadioButtonCourant.Checked = Not TousDoc
        Select Case TypeFusion
            Case 1
                FormFusion.RadioButtonMatchs.Checked = True
            Case 2
                FormFusion.RadioButtonSubMatchLignes.Checked = True
            Case 3
                FormFusion.RadioButtonSubMatchCol.Checked = True
            Case 4
                FormFusion.RadioButtonModele.Checked = True
            Case Else
        End Select
        If Regex <> "" Then
            FormFusion.RadioButtonRegEx.Checked = True
            FormFusion.TextBoxRegEx.Text = Regex
            FormFusion.RichTextBox1.Text = Modele
        Else
            FormFusion.RadioButtonRegEx.Checked = False
        End If
        Call FormFusion.Fusionner()
        Call Form1.Nouveau()
        Form1.RichTextBox1.Visible = False
        Form1.RichTextBox1.Text = FormFusion.sResultGlobal
        Form1.DocumentCourant.Contenu = FormFusion.sResultGlobal
        Call Form1.RechercherMarqeursDocCourant()
        Call Form1.UpdateCompteurs()
        Call Form1.UpdateStatus()
        Form1.RichTextBox1.Visible = True
    End Sub

    Public Sub AjouterLigne(ByVal Ligne As String)
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        If Form1.RichTextBox1.TextLength > 0 Then Form1.RichTextBox1.Text &= vbLf
        Form1.RichTextBox1.Text &= Ligne
        AllerFin()
    End Sub

    Public Sub AjouterTexte(ByVal Chaine As String)
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Form1.RichTextBox1.Text &= Chaine
        AllerFin()
    End Sub

    Public Function Aligner(ByVal Chaine As String, ByVal Sep As String) As String
        Return Commun.Aligner(Chaine, Sep)
    End Function

    Public Sub AllerDebut()
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Form1.RichTextBox1.SelectionLength = 0
        Form1.RichTextBox1.SelectionStart = 0
    End Sub

    Public Sub AllerFin()
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Form1.RichTextBox1.SelectionLength = 0
        Form1.RichTextBox1.SelectionStart = Form1.RichTextBox1.TextLength
    End Sub

    Public Sub AllerPrecedent()
        Call Form1.AllerPrecedent()
    End Sub

    Public Sub AllerSuivant()
        Call Form1.AllerSuivant()
    End Sub

    Public Sub AnnulerTout()
        Form1.ResetCourant()
    End Sub

    Public Sub AtteindreLigne(ByVal NoLigne As Integer)
        Form1.AtteindreLigneAuto(NoLigne)
    End Sub

    Public ReadOnly Property CheminFichier() As String
        Get
            If Not Form1.DocumentCourant Is Nothing Then
                Return Form1.DocumentCourant.Chemin
            Else
                Return ""
            End If
        End Get
    End Property

    Public Sub Coller()
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Form1.Coller()
    End Sub

    Public Sub CollerColonne()
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Form1.CollerColonne()
    End Sub

    Public Function CompterFichiers(ByVal sRef As String, ByVal sRegex As String, ByVal sChaineRecherchee As String, ByVal sRapport As String, ByVal dossier As String, ByVal Masque As String, ByVal bRecurse As Boolean)
        Return Commun.CompterFichiers(sRef, sRegex, sChaineRecherchee, sRapport, dossier, Masque, bRecurse)
    End Function

    Public Sub Copier()
        Form1.Copier()
    End Sub

    Public Sub CopierAjouter()
        Form1.CopierAjouter()
    End Sub

    Public Sub CopierEnregistrerFichierSous(ByVal Chemin As String)
        Form1.DocumentCourant.Contenu = Form1.RichTextBox1.Text
        Form1.DocumentCourant.ContenuRTF = Form1.RichTextBox1.Rtf
        Dim oDocTemp As ClassDocument = Form1.DocumentCourant
        Call Me.Nouveau()
        Form1.RichTextBox1.Rtf = oDocTemp.ContenuRTF
        Call EnregistrerFichierSous(Chemin)
        Call Form1.AfficherProprietes()
    End Sub

    Public Sub CopierNomCourant()
        Call Form1.CopierNomCourant()
    End Sub

    Public Sub CopierNomsFichiersOuverts()
        Call Form1.CopierNomsFichiersOuverts()
    End Sub

    Public Sub CopierVers(ByVal CheminDossier As String, ByVal bFermer As Boolean)
        Call Form1.CopierVersAuto(CheminDossier, bFermer)
    End Sub

    Public Sub Couper()
        Form1.Couper()
    End Sub

    Public Sub Dupliquer()
        Form1.Dupliquer()
    End Sub

    Public Function Encadrer(ByVal Chaine As String, ByVal Car As Char) As String
        Return Commun.Encadrer(Chaine, Car)
    End Function


    Public Function EnregistrerFichier() As Boolean
        If Not Form1.DocumentCourant Is Nothing Then
            Form1.DocumentCourant.Contenu = Form1.RichTextBox1.Text
            Form1.DocumentCourant.ContenuRTF = Form1.RichTextBox1.Rtf
            Form1.Enregistrer(Form1.DocumentCourant)
            Return True
        Else
            Return False
        End If
    End Function

    Public Function EnregistrerFichierSous(ByVal Chemin As String) As Boolean
        If Not Form1.DocumentCourant Is Nothing Then
            Form1.DocumentCourant.Contenu = Form1.RichTextBox1.Text
            Form1.DocumentCourant.ContenuRTF = Form1.RichTextBox1.Rtf
            Form1.EnregistrerSous(Form1.DocumentCourant, Chemin)
            Return True
        Else
            Return False
        End If
    End Function

    Public Function FermerFichier() As String
        Dim sChemin As String = ""
        If Not Form1.DocumentCourant Is Nothing Then
            Form1.Fermer(Form1.DocumentCourant)
            If Not Form1.DocumentCourant Is Nothing Then sChemin = Form1.DocumentCourant.Chemin
        End If
        Return sChemin
    End Function

    Public Sub FermerSansMarque()
        Call Form1.FermerSansMarques()
    End Sub

    Public Sub FermerTous()
        Call Form1.FermerTous()
    End Sub

    Public Sub FermerTousSaufCourant()
        Call Form1.FermerTousSaufCourant()
    End Sub

    Public Function FichiersOuverts() As Collection
        Dim oCol As New Collection
        For Each oItem As ListViewItem In Form1.ListViewFichiers.Items
            Dim oDoc As ClassDocument = oItem.Tag
            oCol.Add(oDoc.Chemin.ToLower)
        Next
        Return oCol
    End Function

    Public Function GetComputer() As String
        Return My.Computer.Name()
    End Function

    Public Function GetDossier() As String
        Return Form1.GetFolderName()
    End Function

    Public Function GetFichier(ByVal sFiltre As String)
        Return Form1.GetFIleName(sFiltre)
    End Function

    Public Function GetFragment(ByVal IdFragment As String) As String
        If Form1.ProjetCourant.ColFragments.Contains(IdFragment) Then
            'Insertion
            Dim oFragment As ClassFragment = Form1.ProjetCourant.ColFragments.Item(IdFragment)
            Return oFragment.Contenu
        Else
            Return ""
        End If
    End Function

    Public Function GetInfoAD(ByVal sFiltre As String, ByVal sDomaine As String, ByVal sUserName As String, ByVal sPassword As String)
        Return Form1.GetInfoAD(sFiltre, sDomaine, sUserName, sPassword)
    End Function

    Public Function GetNouveauNom(ByVal Filtres As String) As String
        Return Form1.GetNewFileName(Filtres)
    End Function

    Public Function GetTexteMarque(Optional sFormat As String = "$0") As Collection
        'On doit retourner une collection utilisable en vbscript
        Dim oCol As New Collection
        For Each sTexte As String In Form1.GetTexteMarque(sFormat)
            oCol.Add(sTexte)
        Next
        Return oCol
    End Function

    Public Function GetUser() As String
        Return My.User.Name()
    End Function

    Public Sub IMporterMarqueursProjet(ByVal Chemin As String)
        Form1.ImporterMarqueursProjet(Chemin)
    End Sub

    Private Sub ImprimerCourant()
        Call Form1.ImprimerCourantAuto()
    End Sub

    Public Sub ImprimerTous()
        Call Form1.IMprimerTousAuto()
    End Sub

    Public Sub IndentText(ByVal NbColonnes As Integer)
        Call Form1.IndentText(NbColonnes)
    End Sub

    Public Sub InsererFinTagXML()
        Call Form1.InsererFinTag()
    End Sub

    Public Sub InsererLigneApres(ByVal Ligne As String)
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Dim NoLigne = Form1.RichTextBox1.GetLineFromCharIndex(Form1.RichTextBox1.SelectionStart)
        If NoLigne = (Form1.RichTextBox1.Lines.Count - 1) Then
            Call Me.AjouterLigne(Ligne)
        Else
            NoLigne += 1
            Form1.RichTextBox1.SelectionStart = Form1.RichTextBox1.GetFirstCharIndexFromLine(NoLigne)
            Form1.RichTextBox1.SelectionLength = 0
            Form1.RichTextBox1.SelectedText = Ligne & vbLf
        End If
    End Sub

    Public Sub InsererLigneAvant(ByVal Ligne As String)
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Dim NoLigne = Form1.RichTextBox1.GetLineFromCharIndex(Form1.RichTextBox1.SelectionStart)
        Form1.RichTextBox1.SelectionStart = Form1.RichTextBox1.GetFirstCharIndexFromLine(NoLigne)
        Form1.RichTextBox1.SelectionLength = 0
        Form1.RichTextBox1.SelectedText = Ligne & vbLf
    End Sub

    ' NOUVEAUX ÉLÉMENTS À DOCUMENTER

    Public Sub InsererMasques()
        Call Form1.ExtraireMasques()
    End Sub

    Public Sub InsererTexte(ByVal Chaine As String)
        If Not Chaine Is Nothing Then
            If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
            If Form1.RichTextBox1.SelectionLength > 0 Then
                Form1.RichTextBox1.SelectionStart += Form1.RichTextBox1.SelectionLength
                Form1.RichTextBox1.SelectionLength = 0
            End If
            Form1.RichTextBox1.SelectedText = Chaine
        End If
    End Sub

    Public Function LireFichier(ByVal sFichier As String) As String
        Dim sContenu As String = ""
        Try
            sContenu = My.Computer.FileSystem.ReadAllText(sFichier, System.Text.Encoding.Default) & vbCrLf
        Catch Ex As Exception
            sContenu = "Erreur à la lecture du fichier " & sFichier & ": " & Ex.Message
        End Try
        Return sContenu
    End Function

    Public Sub MajMarqueurs()
        Form1.RechercherMarqueurs()
    End Sub

    Public Function MettreEnColonnes(ByVal Chaine As String, ByVal Sep As String) As String
        Return Commun.MettreEnColonnes(Chaine, Sep)
    End Function

    Public Sub Nouveau()
        Form1.Nouveau()
    End Sub

    Public Sub NouveauMarqueur(ByVal Titre As String, ByVal Masque As String, ByVal CoulFP As String, ByVal CoulFS As String, ByVal CoulTP As String, ByVal CoulTS As String, ByVal bCasse As Boolean, ByVal bPropager As Boolean, ByVal bSouligner As Boolean, ByVal bAutoCoul As Boolean, ByVal Modele As String, ByVal Condition As String)
        Form1.NouveauMarqueurAuto(Titre, Masque, CoulFP, CoulFS, CoulTP, CoulTS, bCasse, bPropager, bAutoCoul, Modele, Condition)
    End Sub

    Public Function Numeroter(ByVal Chaine As String) As String
        Return Commun.Numeroter(Chaine)
    End Function

    Public Function OuvrirFichier(ByVal Chemin As String) As Boolean
        If System.IO.File.Exists(Chemin) Then
            Form1.OuvrirFichier(Chemin)
            Return SelectFichier(Chemin)
        Else
            Return False
        End If
    End Function

    Public Sub OuvrirFichiersMarqueurs()
        Form1.OuvrirFichiersMarqueursAuto()
    End Sub

    Public Sub OuvrirFichiersSelection()
        Form1.OuvrirFichiersSelectionAuto()
    End Sub

    Public Sub OuvrirListe(ByVal sListeName As String)
        Call Form1.OuvrirListeAuto(sListeName)
    End Sub

    Public Sub RechargerCourant()
        Form1.RechargerCourantAuto()
    End Sub

    Public Sub Redo()
        Form1.Redo()
    End Sub

    Public Sub ReformaterXML()
        Call Form1.ReformaterXML()
    End Sub

    Public Sub RemplacerTexte(ByVal Chaine As String)
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Form1.RichTextBox1.SelectedText = Chaine
    End Sub

    Public Function RunPowerShell(ByVal Commande As String) As String
        Return Commun.RunPowerShell(Commande)
    End Function

    Public Function RunShell(ByVal Commande As String) As String
        Return Commun.RunShell(Commande)
    End Function

    Public Function SelectFichier(ByVal Chemin As String) As Boolean
        If Form1.ListViewFichiers.Items.ContainsKey(Chemin.ToLower) Then
            Form1.ListViewFichiers.Items(Chemin.ToLower).Selected = True
            Form1.AfficheCourant(Form1.ListViewFichiers.Items(Chemin.ToLower))
            Return True
        Else
            Return False
        End If
    End Function

    Public Sub Selection(ByVal Debut As Integer, ByVal Longueur As Integer)
        Form1.RichTextBox1.SelectionStart = Debut
        Form1.RichTextBox1.SelectionLength = Longueur
    End Sub

    Public Property SelectionDebut() As Integer
        Get
            Return Form1.RichTextBox1.SelectionStart
        End Get
        Set(ByVal value As Integer)
            Form1.RichTextBox1.SelectionStart = value
        End Set
    End Property

    Public Property SelectionLongueur() As Integer
        Get
            Return Form1.RichTextBox1.SelectionLength
        End Get
        Set(ByVal value As Integer)
            Form1.RichTextBox1.SelectionLength = value
        End Set
    End Property

    Public Sub SelectionnerTout()
        If Form1.DocumentCourant Is Nothing Then Call Form1.Nouveau()
        Form1.RichTextBox1.SelectAll()
    End Sub

    Public Property SelectionTexte() As String
        Get
            Return Form1.RichTextBox1.SelectedText
        End Get
        Set(ByVal value As String)
            Form1.RichTextBox1.SelectedText = value
        End Set
    End Property

    Public Sub SupprimeColonne()
        Call Form1.DeleteColonne()
    End Sub

    Public Sub SupprimeLigne()
        Call Form1.DeleteLigne()
    End Sub

    Public Sub SupprimerCourant()
        Call Form1.SupprimerCourantAuto()
    End Sub

    Public Function SupprimerLignesDoubles(ByVal Chaine As String) As String
        Return Commun.SupprimerLignesDoubles(Chaine)
    End Function

    Public Sub SupprimerMarqueur(ByVal Titre As String)
        If Form1.ListViewMarqueurs.Items.ContainsKey(Titre) Then
            Form1.ListViewMarqueurs.Items(Titre).Tag = Nothing
            Form1.ListViewMarqueurs.Items.RemoveByKey(Titre)
        End If
    End Sub

    Public Sub SupprimerTexteMarque()
        Call Form1.SupprimerMarqueCourant()
        Call Form1.AfficherStatistiquesGlobales()
    End Sub

    Public Sub SupprimerTousMarqueurs()
        Form1.ListViewMarqueurs.Items.Clear()
    End Sub

    Public Property Texte() As String
        Get
            Return Replace(Form1.RichTextBox1.Text, vbLf, vbCrLf)
        End Get
        Set(ByVal value As String)
            Form1.RichTextBox1.Text = value
        End Set
    End Property

    'Fonctions de transformation
    Public Sub RemplacerTexte(ByRef Texte As String, ByVal Chaine As String, ByVal par As String)
        Texte = TransformerChaine(Texte, ClassTextOp.EnumTextOperation.RemplacerTexte, Chaine, par)
    End Sub

    Public Sub Transformer(ByVal Op As String, Optional Param1 As String = "", Optional Param2 As String = "", Optional Param3 As String = "", Optional Param4 As String = "")
        'Transformation appliquée à tout le texte
        Dim oTextOP As New ClassTextOp
        If [Enum].IsDefined(GetType(ClassTextOp.EnumTextOperation), Op) Then oTextOP.Operation = [Enum].Parse(GetType(ClassTextOp.EnumTextOperation), Op, True)
        oTextOP.Parametres(0) = Param1
        oTextOP.Parametres(1) = Param2
        oTextOP.Parametres(2) = Param3
        oTextOP.Parametres(3) = Param4
        Form1.RichTextBox1.Text = oTextOP.Transformer(Form1.RichTextBox1.Text)
        Form1.DocumentCourant.Contenu = Form1.RichTextBox1.Text
        oTextOP = Nothing
    End Sub

    Public Sub TransformerSelection(ByVal Op As String, Optional Param1 As String = "", Optional Param2 As String = "", Optional Param3 As String = "", Optional Param4 As String = "")
        'Transformation appliquée à tout le texte
        Dim oTextOP As New ClassTextOp
        If [Enum].IsDefined(GetType(ClassTextOp.EnumTextOperation), Op) Then oTextOP.Operation = [Enum].Parse(GetType(ClassTextOp.EnumTextOperation), Op, True)
        oTextOP.Parametres(0) = Param1
        oTextOP.Parametres(1) = Param2
        oTextOP.Parametres(2) = Param3
        oTextOP.Parametres(3) = Param4
        If Form1.RichTextBox1.SelectedText <> "" Then Form1.RichTextBox1.SelectedText = oTextOP.Transformer(Form1.RichTextBox1.SelectedText)
        Form1.DocumentCourant.Contenu = Form1.RichTextBox1.Text
        oTextOP = Nothing
    End Sub

    Public Overloads Function TransformerChaine(ByVal Chaine As String, ByVal Op As String, Optional Param1 As String = "", Optional Param2 As String = "", Optional Param3 As String = "", Optional Param4 As String = "") As String
        Dim oTextOP As New ClassTextOp
        If [Enum].IsDefined(GetType(ClassTextOp.EnumTextOperation), Op) Then oTextOP.Operation = [Enum].Parse(GetType(ClassTextOp.EnumTextOperation), Op, True)
        oTextOP.Parametres(0) = Param1
        oTextOP.Parametres(1) = Param2
        oTextOP.Parametres(2) = Param3
        oTextOP.Parametres(3) = Param4
        Return oTextOP.Transformer(Chaine)
        oTextOP = Nothing
    End Function

    Public Sub TransformerMarqueurs(ByVal Op As String, Optional Param1 As String = "", Optional Param2 As String = "", Optional Param3 As String = "", Optional Param4 As String = "")
        If Form1.DocumentCourant Is Nothing Then Exit Sub
        Dim oTextOP As New ClassTextOp
        Dim Visible As Boolean = Form1.RichTextBox1.Visible
        If [Enum].IsDefined(GetType(ClassTextOp.EnumTextOperation), Op) Then oTextOP.Operation = [Enum].Parse(GetType(ClassTextOp.EnumTextOperation), Op, True)
        oTextOP.Parametres(0) = Param1
        oTextOP.Parametres(1) = Param2
        oTextOP.Parametres(2) = Param3
        oTextOP.Parametres(3) = Param4
        Call Form1.TransformerRecCourant(oTextOP)
        Form1.RichTextBox1.Visible = Visible
        oTextOP = Nothing
        Dim coco As String = "RemplacerTexte"
    End Sub

    Public Function Trier(ByVal Chaine As String, ByVal Sep As String)
        Return Commun.Trier(Chaine, Sep)
    End Function

    Public Sub TrierTexteMarque()
        Call Form1.TrierTexteMarque()
    End Sub

    Public Function TrimLignesBlanches(ByVal Chaine As String) As String
        Return Commun.TrimLignesBlanches(Chaine)
    End Function

    Public Sub Undo()
        Form1.Undo()
    End Sub

    Public Sub UndoAll()
        Form1.UndoAll()
    End Sub

    Public Function CompteMots(ByVal Chaine As String) As Integer
        Return Commun.CompteMots(Chaine)
    End Function
End Class
